using System;
using System.Data;
using System.Configuration;
using System.Web;
//using System.Web.Security;
//using System.Web.UI;
//using System.Web.UI.WebControls;
//using System.Web.UI.WebControls.WebParts;
//using System.Web.UI.HtmlControls;
using BUS;
using DTO;
/// <summary>
/// Summary description for NguoiMuaHangDAO
/// </summary>
public class NguoiMuaHangDAO : SqlDataHelper
{
    private string table;
    public NguoiMuaHangDAO()
	{
		//
		// TODO: Add constructor logic here
		//
        this.table = "NguoiMuaHang";
	}
    public bool th_KiemTraTenDangNhap(string tendangnhap) {

        string sql;
        DataSet ds;
        try
        {
            sql ="select TenDangNhap from "+ this.table+" where TenDangNhap ='"+ tendangnhap +"'";
            ds = new DataSet();
            ds = this.ExecuteQuery(sql);

            if (ds.Tables[0].Rows.Count > 0)
                return true;
            return false;
        }
        catch 
        {
            return false;
        }

    }
    public bool th_ThemKhachHang(NguoiGiaoDichDTO gd, NguoiMuaHangDTO mh ) {
        string sql;
        bool check = false;
        //DataTable dt;
        try
        {
            sql = "insert into " + this.table;
            sql += "(TenDangNhap,MatKhau,HoTen,TenCongTy,DiaChi,DienThoai,Email) values('";
            sql += mh.Tendangnhap + "','";
            sql += mh.Matkhau + "',N'";
            sql += gd.Hoten + "',N'";
            sql += mh.Tencongty + "',N'";
            sql += gd.Diachi + "','";
            sql += gd.Dienthoai + "','";
            sql += mh.Email + "')";

            check = this.ExecuteNonQuery(sql);
            
            return check;
        }
        catch
        {
            return check;
        }
    }


}
